<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="sec"
	uri="http://www.springframework.org/security/tags"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<sec:authentication property="principal" var="currentPrincipal"
	scope="page" />

<fmt:setBundle basename="ApplicationMessage" />
<fmt:setLocale value="zh_CN" />

<!DOCTYPE html>
<html lang="zh-CN">
<head>

<%@ include file="/WEB-INF/include/meta.jsp"%>
<%@ include file="/WEB-INF/include/css.jsp"%>

</head>

<body class="ms-theme-blue">

	<%@ include file="/WEB-INF/include/header.jsp"%>

	<%@ include file="/WEB-INF/include/menu.jsp"%>
	<div class="container-fluid ms-container has-ms-sidemenu">

		<ol class="ms-breadcrumb breadcrumb">
			<li class="active">优惠券使用&nbsp;&nbsp;-&nbsp;&nbsp;详情</li>
			<li class="no-before pull-right" style="min-width: 65px;">
            <a onclick="window.history.back();"><i class="glyphicon glyphicon-arrow-left"></i>&nbsp;&nbsp;返回</a>
          </li>
		</ol>

		<div class="col-xs-2 x-panel-layout-left no-horizontal-padding">
			<%@ include file="/WEB-INF/include/submenu.jsp"%>
		</div>

		<div class="ms-content-layout has-operation ">
		  <div class="">

			  <div class="ms-operation-bar no-margin no-bottom-border clearfix">
				  <div class="ms-operation-group pull-right">
					  <a href="${ctx.host}/coupon-use/search${not empty queryString ? '?'.concat(queryString) : ''}" class="btn ms-btn ms-btn-blue" data-target="#export" data-toggle="modal">
						  <i class="glyphicon glyphicon-search"></i>&nbsp;&nbsp;过滤查询
					  </a>
				  </div>
			  </div>
			
				<table class="table table-hover ms-table">
					<thead>
						<tr>
							<th class="text-center">优惠券码</th>
							<th class="text-center">姓名</th>
							<th class="text-center">手机</th>
							<th class="text-center">批次</th>
							<th class="text-center">开始日期</th>
							<th class="text-center">截止日期</th>
							<th class="text-center">状态</th>
							<th class="text-center">使用时间</th>
						</tr>
					</thead>

					<tbody>
						<c:choose>
							<c:when test="${empty useCoupons}">
								<tr>
									<%-- <td colspan="9" style="text-align: center;">不存在券码为${code}的礼品券</td> --%>
									<td colspan="9" style="text-align: center;">暂无已使用优惠券</td>
									
								</tr>
							</c:when>
							<c:otherwise>
								<c:forEach items="${useCoupons}" var="coupon">
								<tr>
									<td class="text-center">${coupon.code}</td>
									<td class="text-center">${coupon.userName}</td>
									<td class="text-center">${coupon.mobile}</td>
									<td class="text-center">${coupon.batchName}</td>
									<td class="text-center"><fmt:formatDate
											value="${coupon.effectiveStartDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
									<td class="text-center"><fmt:formatDate
											value="${coupon.effectiveEndDate}" pattern="yyyy-MM-dd HH:mm:ss" /></td>
									<td class="text-center"><c:choose>
											<c:when
												test="${coupon.status == 'CLAIMED' && coupon.restDay <= 0}">
												<span class="label label-default">已过期</span>
											</c:when>
											<c:otherwise>
												<span class="label label-${coupon.status.css}">${coupon.status.description}</span>
											</c:otherwise>
										</c:choose></td>
									<td class="text-center"><fmt:formatDate
											value="${coupon.useTime}" pattern="yyyy-MM-dd HH:mm:ss" /></td>

								</tr>
								</c:forEach>
							</c:otherwise>
						</c:choose>
					</tbody>

				</table>

			</div>
		</div>

	</div>

	<%@ include file="/WEB-INF/include/footer.jsp"%>
	<%@ include file="/WEB-INF/include/script.jsp"%>
	<d:resource root="${ctx.resource}/build" type="script"
		src="js/page/encommerce/coupon/coupon-batch-view.js">
		<script type="text/javascript">
			require([ 'page/encommerce/coupon/coupon-batch-view' ], function(
					page) {
				page.init()
			})
		</script>
	</d:resource>
</body>
</html>